'use strict';

module.exports = app => {
  const { STRING, INTEGER, BOOLEAN, TEXT } = app.Sequelize;

  const User = app.model.define('user', {
    id: { type: INTEGER, primaryKey: true, autoIncrement: true },
    open_id: STRING,
    nick: STRING,
    city: STRING,
    age: INTEGER,
    head_image: STRING,
    wechat: STRING,
    phone: STRING,
    profession: STRING,
    company: STRING,
    favour: INTEGER,
    desc: TEXT,
    role_id: INTEGER,
    money: INTEGER,
    authentication: BOOLEAN,
  });

  User.associate = function() {
    app.model.User.belongsTo(app.model.Role, { foreignKey: 'role_id', targetKey: 'id' });
  };

  return User;
};
